home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 2000 #2 / Sun Solutions CD (Volume 2 2000)(Special Focus - Java Technologies)(Disc 1).ISO / products / Software / EasysoftLimited / _install / launchit.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2000-02-10  |  6KB  |  271 lines

  1. #!/bin/sh 
  2. if [ "$HOME" = "" ]; then
  3.         HOME="/"; export HOME
  4. fi
  5. #
  6. # Generic launch script for use with MDSS cdrom mechanism 
  7. #
  8. # marc.sacoolas@sun.com 
  9. #
  10. #**********************
  11. #     Begin subs
  12. #**********************
  13.  
  14. # Check if user wants to be root 
  15. check_root_maybe() {
  16. if [ "$USER" != "root" ]; then
  17.   while true
  18.   do
  19.     echo ""
  20.     echo "You may need to be root user to install this software in certain directories. \c"
  21.     echo ""
  22.     echo "Would you like to become root user? <[y/n] n> \c"
  23.     read ans
  24.      if [ "$ans" = "" ]; then 
  25.     ans="n" 
  26.      fi
  27.  
  28.      case "$ans" in
  29.       y|Y|yes|YES) echo "";echo "Enter super user \c";su root -c 'USER=root;export USER;$COMPANY_DIR/_install/launchit.sh $theARGS';exit 0
  30.             ;;
  31.       N|Q|n|q|No|quit|NO|QUIT|Quit) break 
  32.             ;;
  33.      esac
  34.   done
  35. fi 
  36. }
  37. # Check if root - manditory
  38. check_root() {
  39. if [ "$USER" != "root" ]; then
  40.   while true
  41.   do
  42.     echo ""
  43.     echo "You need to be super user to install this software. \c"
  44.     echo ""
  45.     echo "Would you like to continue with the installation? <[y/n] y> \c"
  46.     read ans
  47.      if [ "$ans" = "" ]; then 
  48.     ans="y" 
  49.      fi
  50.  
  51.      case "$ans" in
  52.       y|Y|yes|YES) echo "";echo "Enter super user \c";su root -c 'USER=root;export USER;$COMPANY_DIR/_install/launchit.sh $theARGS';exit 0
  53.             ;;
  54.       N|Q|n|q|No|quit|NO|QUIT|Quit) end_it
  55.             ;;
  56.      esac
  57.   done
  58. fi 
  59. }
  60. # terminate installation
  61. end_it () {
  62.   echo " " 
  63.   echo $1
  64.   echo " " 
  65.   echo "Hit return to end ..."
  66.   echo " "
  67.   read answer
  68.   exit 0 
  69. }
  70. # prompt to remove stuff before terminating 
  71. end_it_rm () {
  72. cd $HOME
  73. echo ""
  74. echo "Remove demo directory $installdir?"
  75.         echo "\n<[y/n] y>\c";read x
  76.         if [ "$x" = "" ];then x="y"
  77.         fi
  78.         if [ $x = "n" -o $x = "no" -o $x = "No" -o $x = "N" ];then
  79.         exit 0
  80.     fi
  81.         if [ $x = "y" -o $x = "yes" -o $x = "Yes" -o $x = "Y" ];then
  82.           rm -rf $installdir
  83.       echo " "
  84.         echo "Hit return to end ..."
  85.         echo " "
  86.           read answer
  87.           exit 0
  88.           if [ -d $path ]; then
  89.                 echo ""
  90.                 echo "Could not remove installation directory."
  91.                 echo ""
  92.         end_it
  93.           fi
  94.         else
  95.       end_it_rm
  96.         fi
  97. }
  98.  
  99. # if prompt is required, do so
  100. prompt_choice() {
  101.   echo ""
  102.   echo "Which package from Easysoft would you like to install?\n"
  103.   echo ""
  104.   echo "1) Easysoft JDBC-ODBC Bridge"
  105.   echo "2) Easysoft ODBC-ODBC Bridge"
  106.   echo "3) Exit Installation" 
  107.   echo ""
  108.   echo "Enter your selection:  \c"
  109.   read answer
  110.  
  111.   case "$answer" in
  112.      1) WHICHPROD="es-jdbc-odbc-bridge-1.0.0.0.sunos.tar.Z"
  113.         WHICHPRODNAME="Easysoft JDBC-ODBC Bridge"
  114.         SOFTPATH=$COMPANY_DIR/_install
  115.         WHICHDIR="jdbc-odbc-bridge-1.0.0.0.sunos"
  116.         ;;
  117.      2)    WHICHPROD="odbc-odbc-bridge-1.0.0.4.sunos.tar.Z" 
  118.     WHICHPRODNAME="Easysoft ODBC-ODBC Bridge" 
  119.         SOFTPATH=$COMPANY_DIR/_install
  120.     WHICHDIR="odbc-odbc-bridge-1.0.0.4.sunos"
  121.     ;;
  122.      3) end_it  
  123.     ;;
  124.      *) echo "Please choose one."
  125.     prompt_choice
  126.     ;;
  127.   esac
  128. }
  129. # if choice driven by .demosh script:
  130. auto_choice () {
  131.   case "$1" in
  132.      1) WHICHPROD=""
  133.         WHICHPRODNAME=""
  134.         install_script=""
  135.         ;;
  136.      2) WHICHPROD="NotifyServer"
  137.         WHICHPRODNAME="IPnetWATCHER Notification Server"
  138.         installdir=NotificationServer11woJRE
  139.         ;;
  140.   esac   
  141.  
  142. }
  143. # if system installation is required
  144. prompt_path () {
  145. installdir="$HOME"
  146. echo ""
  147. echo "Please enter an install path to begin installing $WHICHPRODNAME:"
  148.  
  149. echo "\n<$installdir>\c";read path
  150. if [ -n "$path" ]; then
  151. installdir="$path"
  152. fi
  153. verify_path $installdir
  154. }
  155.  
  156. verify_path () {
  157. installdir=$1
  158. if [ ! -d $installdir ]; then
  159.         echo "$installdir does not exist, create it?"
  160.     echo "\n<[y/n] y>\c";read x
  161.     if [ "$x" = "" ];then x="y"
  162.     fi
  163.     if [ $x = "y" -o $x = "yes" -o $x = "Yes" -o $x = "Y" ];then 
  164.           mkdir -p $installdir
  165.           if [ ! -d $installdir ]; then
  166.         echo ""
  167.                 echo "Could not create destination directory."
  168.                 prompt_path 
  169.           fi
  170.     else
  171.       end_it "A destination directory needs to be specified."
  172.     fi
  173. fi
  174. if [ ! -w $installdir ];then
  175.     echo "You can not write to $installdir" 
  176.     prompt_path
  177. fi
  178.  
  179. FREE_SPACE=0
  180. df=/tmp/FREE.$$
  181. /usr/bin/df -k $installdir | sed /kbytes/d | sed -e '3,$d' | sed -e '1,$s/  */ /g' > $df
  182. case `/usr/bin/wc -l $df | sed -e 's/^ *//' | cut -f1 -d" " ` in
  183.         1) FREE_SPACE=`cat $df | cut -f4 -d" "` ;;
  184.         2) FREE_SPACE=`cat $df | sed 1d | sed 's/^ *//' | cut -f3 -d" "` ;;
  185. esac
  186. if [ -n $FREE_SPACE ]
  187. then
  188.         if [ $FREE_SPACE -lt $PRODUCT_SIZE ]
  189.         then
  190.            echo
  191.            echo "The product installation requires $PRODUCT_SIZE kbytes of"
  192.            echo "free disk space. There is only $FREE_SPACE kbytes of free"
  193.            echo "disk space in the selected filesystem.  Please free up some"
  194.            echo "disk space, or choose another directory."
  195.                 prompt_path
  196.         fi
  197. fi
  198. /bin/rm $df 2>/dev/null
  199.  
  200. return 0 
  201. }
  202.  
  203. #*****************
  204. #  end subs
  205. #*****************
  206.  
  207. #Variables
  208. theARGS=$1
  209. PRODUCT_SIZE='250000'
  210. WHICHPROD=
  211. WHICHPRODNAME=
  212. installdir=/tmp/demo.$$
  213. export PRODUCT_SIZE WHICHPROD WHICHPRODNAME installdir theARGS
  214.  
  215.   echo ""
  216.   echo 
  217.  
  218. ##  Call out Subs here ###
  219.  
  220. check_root
  221. #check_root_maybe
  222. #auto_choice $theARGS
  223. prompt_choice
  224. #prompt_path
  225.  
  226.  
  227. # below is custom for each demo
  228.  
  229. echo ""
  230. echo "$WHICHPRODNAME software installation starting..."
  231. echo ""
  232. echo "installdir = $installdir" >> /tmp/mje
  233. mkdir -p $installdir
  234. #verify_path $installdir
  235. chmod -R 777 $installdir
  236. cd $installdir
  237.  
  238. echo ""
  239. echo "Launching $WHICHPRODNAME installation ..."
  240. echo ""
  241. echo "zcat $SOFTPATH/$WHICHPROD | tar xf -" >> /tmp/mje
  242. zcat $SOFTPATH/$WHICHPROD | tar xf - 
  243. cd $WHICHDIR
  244. ./install
  245.  
  246. #$CD_MOUNT/products/bin/java/$CDWARE_ENV/bin/jre pointbasemobile228r 
  247.  
  248. #         if [ "$WHICHPROD" = "*.Z" ]
  249. #         then
  250. #             cp $SOFTPATH/client/* $installdir 
  251. #             cd $installdir
  252. #             chmod 777 *
  253. #             ./install
  254. #         else
  255. #             cp -r $SOFTPATH/server/* $installdir 
  256. #             cd $installdir
  257. #             chmod 777 *       
  258. #             ./install
  259. #         fi
  260. #CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/jar.jar
  261. #export CLASSPATH
  262.  
  263. cd $COMPANY_DIR
  264. rm -fr $installdir
  265.  
  266. end_it
  267.  
  268.  
  269.  
  270.  
  271.